package com.hank.tetris;

import lombok.Getter;
import lombok.Setter;

import java.awt.*;


/**
 * 第一个格子类
 */

@Getter
@Setter
public class Cell {
    private int col;
    private int row;
    private Color color;

    public Cell(int row,int col, Color color) {
        this.row = row;
        this.col = col;
        this.color = color;
    }

    public int getCol() {
        return col;
    }

    public void setCol(int col) {
        this.col = col;
    }

    public void setRow(int row) {
        this.row = row;
    }

    public int getRow() {
        return row;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public Color getColor() {
        return color;
    }

    /*
     *drop控制下降
     */
    public void drop(){
        row++;
    }

    /*
     *moveRight 右移动
     */
    public void moveRight(){
        col++;
    }

    /*
     *moveLeft 左移动
     */
    public void moveLeft(){
        col--;
    }

    public void paint(Graphics g){
        g.setColor(this.color);
        g.fill3DRect(col * Tetris.CELL_UNIT,row*Tetris.CELL_UNIT,Tetris.CELL_UNIT,Tetris.CELL_UNIT,true);
    }

    public String toString(){
        return col +","+row;
    }
}